<template>
  <div>
    <van-nav-bar
      title="我的订单"
      left-text=""
      right-text=""
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickLeft"
    />
    <van-card v-for="orders in ordersList"
      
      :price="orders.price"
      :desc="orders.description"
      :title="orders.dname"
      :thumb="orders.pic"
      :key="orders.id">
      <template #tags>
        <van-button size="mini"> {{orders.state}}</van-button>
        
      </template>
      <template #footer>
        <van-button plain hairline type="primary" @click="toBusinessPage(orders.bid)">{{orders.bname}}</van-button>
        <van-button plain hairline type="primary" @click="xiangq(orders)">详情</van-button>
      </template>
    </van-card>
  </div>
</template>
<script>
import axios from "axios";

export default {
  data() {
    return {
      show: false,
      uid: sessionStorage.getItem("id"),
      ordersList: [],
    };
  },
  methods: {

    toBusinessPage:function(bid) {
      this.$router.push({
        path: "/BusinessPage",
        query: {
          id: bid
        }
      });
    },
    xiangq:function(orders){
      this.$router.push({
        name:"qzd",
        params:{dui:orders}
      })
    },

    chazhao: function () {
      axios
        .post("http://localhost/take-out-orders/orders/findAll", { id: this.uid })
        .then((res) => {
          if (res.data.code == 200) {
           
            this.ordersList = res.data.data;
          
          }
        });
    },
    onClickLeft(){
      this.$router.go(-1);
    }
  },
  mounted() {
    this.chazhao();
  },
};
</script>
